package com.bit101.components
{
	import flash.display.Bitmap;
	import flash.display.DisplayObjectContainer;
	import flash.events.MouseEvent;
	
	public class ImageChangeBtn extends PushButton
	{
		private var upBitmp:Bitmap;
		private var downBitmap:Bitmap;
		public function ImageChangeBtn(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, label:String="", defaultHandler:Function=null)
		{
			super(parent, xpos, ypos, label, defaultHandler);
		}
		public function setEmbedSource(cls:Class,cls2:Class):void{
			upBitmp = new cls();
			this.addChildAt(upBitmp,0);
			downBitmap = new cls2();
			this.addChildAt(downBitmap,0);
		}
		override public function set selected(value:Boolean):void
		{
			if(!_toggle)
			{
				value = false;
			}
			
			_selected = value;
			
			if(upBitmp == null){
				return;
			}
			if(_selected)
			{
				upBitmp.visible = true;
				downBitmap.visible = false;
			}
			else
			{
				upBitmp.visible = false;
				downBitmap.visible = true;
			}
		}
		override public function draw():void
		{
			//super.draw();
			/*_back.graphics.clear();
			_back.graphics.beginFill(Style.BACKGROUND);
			_back.graphics.drawRect(0, 0, _width, _height);
			_back.graphics.endFill();*/
			
			//drawFace();
			
			_label.text = _labelText;
			_label.autoSize = true;
			_label.draw();
			if(_label.width > _width - 4)
			{
				_label.autoSize = false;
				_label.width = _width - 4;
			}
			else
			{
				_label.autoSize = true;
			}
			//_label.draw();
			_label.move(_width / 2 - _label.width / 2, _height / 2 - _label.height / 2);
			
		}
		override protected function onMouseGoDown(event:MouseEvent):void
		{
			//_down = true;
			//drawFace();
			//_face.filters = [getShadow(1, true)];
			//stage.addEventListener(MouseEvent.MOUSE_UP, onMouseGoUp);
		}
		
	}
}